package com.jwgf.smarowindingmachine_unity.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.HorizontalScrollView;

public class ObservableHorizontalScrollView extends HorizontalScrollView {

	private OnHorizontalScrollChangedListener changedListener = null;

	public interface OnHorizontalScrollChangedListener {
		void onScrollChanged(
				ObservableHorizontalScrollView horizontalScrollView, int x,
				int y, int oldx, int oldy);
	}

	public ObservableHorizontalScrollView(Context context) {
		super(context);
	}

	public ObservableHorizontalScrollView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public ObservableHorizontalScrollView(Context context, AttributeSet attrs,
			int defStyle) {
		super(context, attrs, defStyle);
	}

	public void setHorizontalScrollChangedListener(
			OnHorizontalScrollChangedListener changedListener) {
		this.changedListener = changedListener;
	}

	@Override
	protected void onScrollChanged(int x, int y, int oldx, int oldy) {
		super.onScrollChanged(x, y, oldx, oldy);
		if (changedListener != null) {
			changedListener.onScrollChanged(this, x, y, oldx, oldy);
		}
	}
}
